package com.one.consumer.user.model;

import com.one.common.model.http.base.BaseModel;
import com.one.common.model.http.callback.ObserverOnResultListener;
import com.one.common.view.base.BaseActivity;
import com.one.consumer.user.model.item.AddressItem;
import com.one.consumer.user.model.item.LookUpItem;

import java.util.ArrayList;
import java.util.Map;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/28 3:37 PM
 * description ：
 **/
public class UserModel extends BaseModel<UserApi> {
    public UserModel(BaseActivity mActivity) {
        super(UserApi.class, mActivity);
    }

    /**
     * 地址---用户所有地址列表
     */
    public void getAddressList(String page, ObserverOnResultListener<ArrayList<AddressItem>> listener) {
        Map<String, String> p = getParams();
        p.put("page", page);
        handleOnResultObserver(mApiService.getAddressList(p), listener);
    }

    /**
     * 地址---用户得到地址详情
     */
    public void getAddressDetail(String id, ObserverOnResultListener<AddressItem> listener) {
        Map<String, String> p = getParams();
        p.put("address_id", id);
        handleOnResultObserver(mApiService.getAddressDetail(p), listener);
    }

    /**
     * 地址----用户添加地址， 修改
     */
    public void addAndUpdateAddress(Map<String, String> param, ObserverOnResultListener<Object> listener) {
        Map<String, String> p = getParams();
        p.putAll(param);
        handleOnResultObserver(mApiService.addAndUpdateAddress(p), listener);
    }

    /**
     * 地址---用户修改默认地址
     */
    public void defaultAddress(String id, ObserverOnResultListener<Object> listener) {
        Map<String, String> p = getParams();
        p.put("address_id",id);
        handleOnResultObserver(mApiService.defaultAddress(p), listener);
    }

    /**
     * 地址---用户删除地址
     */
    public void deleteAddress(String id, ObserverOnResultListener<Object> listener) {
        Map<String, String> p = getParams();
        p.put("address_id",id);
        handleOnResultObserver(mApiService.deleteAddress(p), listener);
    }

    /**
     * 地址---获取默认地址
     */
    public void getDefaultAddress(ObserverOnResultListener<AddressItem> listener) {
        Map<String, String> p = getParams();
        handleOnResultObserver(mApiService.getDefaultAddress(p), listener);
    }

    /**
     * 发票----用户的默认发票详情 抬头
     */
    public void getLookUpDefault(ObserverOnResultListener<LookUpItem> listener) {
        Map<String, String> p = getParams();
        handleOnResultObserver(mApiService.getLookUpDefault(p), listener);
    }

    /**
     * 发票----添加发票 ,修改 抬头
     */
    public void addInvoiceLookUp(Map<String, String> param, ObserverOnResultListener<Object> listener) {
        Map<String, String> p = getParams();
        p.putAll(param);
        handleOnResultObserver(mApiService.addInvoiceLookUp(p), listener);
    }

    /**
     * 发票----设置默认发票 抬头
     */
    public void defaultInvoiceLookUp(String id, ObserverOnResultListener<Object> listener) {
        Map<String, String> p = getParams();
        p.put("invoice_id", id);
        handleOnResultObserver(mApiService.defaultInvoiceLookUp(p), listener);
    }

    /**
     * 发票----发票列表 抬头
     */
    public void getLookUpList(String page, ObserverOnResultListener<ArrayList<LookUpItem>> listener) {
        Map<String, String> p = getParams();
        p.put("page", page);
        handleOnResultObserver(mApiService.getLookUpList(p), listener);
    }

    /**
     * 发票----发票详情 抬头
     */
    public void getLookUpDetail(String id, ObserverOnResultListener<LookUpItem> listener) {
        Map<String, String> p = getParams();
        p.put("invoice_id", id);
        handleOnResultObserver(mApiService.getLookUpDetail(p), listener);
    }

    /**
     * 发票----删除发票
     */
    public void deleteLookUp(String id, ObserverOnResultListener<Object> listener) {
        Map<String, String> p = getParams();
        p.put("invoice_id", id);
        handleOnResultObserver(mApiService.deleteLookUp(p), listener);
    }
}
